<?php
/*
Template Name: Shop Brand Top Page
*/
?>

<?php
	global $currentpageid;
	$currentpageid = get_the_ID();
?>

<?php get_header(); ?>
<?php global $woo_options; ?>
       
    <div id="content" class="page col-full">
		<div id="main" class="col-left">
		           
		<?php if ( $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) { ?>
			<?php woo_breadcrumbs(); ?>  
		<?php } ?>  			

        <?php if (have_posts()) : $count = 0; ?>
        <?php while (have_posts()) : the_post(); $count++; ?>
                                                                    
            <div <?php post_class(); ?>>

			    <h1 class="title"><?php the_title(); ?></h1>
                            <?php include '/home/silicons/public_html/wp-content/themes/woostore/page-include-social-block.php'; ?>

                <div class="entry">
                    
                    <?php
	$brandpagelone = new WP_Query('post_type=page&post_parent='.$currentpageid.'&posts_per_page=-1&orderby=menu_order'); ?>
	<?php while ($brandpagelone->have_posts()) : $brandpagelone->the_post(); ?>
    	
        <?php $childpageloneid = get_the_ID(); ?>
        <h2 class="pagesubsectionheader"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <ul class="products">
        	<?php $brandpageltwo = new WP_Query('post_type=page&post_parent='.$childpageloneid.'&posts_per_page=-1&orderby=menu_order'); ?>
            <?php while ($brandpageltwo->have_posts()) : $brandpageltwo->the_post(); ?>
            	<?php $productbrandimage = get_post_meta($post->ID, 'productbrandimage', true); ?>
            	<li class="product" style="height:260px;">
                	<a href="<?php the_permalink(); ?>">
                    	<img class="attachment-shop_catalog wp-post-image" src="../<?php echo $productbrandimage ; ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" width="150" height="150" />
                        <h3 style="margin-bottom:10px;"><?php the_title(); ?></h3>
                    </a>
                    <a href="<?php the_permalink(); ?>" class="button">View Products</a>
                </li>
            <?php endwhile ?>
            <?php wp_reset_postdata(); ?>
        </ul>
        
    <?php endwhile ?>
<?php wp_reset_postdata(); ?>
        
                    <?php the_content(); ?>
        
                    <?php // Include The Contact Block - If Option Is Turned On - Matt B - Apr 2013
                            if (get_field('showcontactblock')) {
                                echo do_shortcode('[contact]');
                        } ?>
                    
                    <?php include 'page-include-why-shop-block.php'; ?>

					<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'woothemes' ), 'after' => '</div>' ) ); ?>
               	</div><!-- /.entry -->

				<?php edit_post_link( __( '{ Edit }', 'woothemes' ), '<span class="small">', '</span>' ); ?>
                
            </div><!-- /.post -->
            
            <?php $comm = $woo_options[ 'woo_comments' ]; if ( ($comm == "page" || $comm == "both") ) : ?>
                <?php comments_template(); ?>
            <?php endif; ?>
                                                
		<?php endwhile; else: ?>
			<div <?php post_class(); ?>>
            	<p><?php _e( 'Sorry, no posts matched your criteria.', 'woothemes' ) ?></p>
            </div><!-- /.post -->
        <?php endif; ?>  
        
		</div><!-- /#main -->

        <?php get_sidebar(); ?>

    </div><!-- /#content -->
		
<?php get_footer(); ?>